package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.TimeUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.bean.StkResBean;

public class StoryAdapter extends StkProviderMultiAdapter<StkResBean> {
    public StoryAdapter() {
        super(8);
        addItemProvider(new StoryItemProvider());
    }

    private class StoryItemProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_story;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
            Glide.with(baseViewHolder.itemView).load(bean.getThumbUrl()).into((ImageView) baseViewHolder.getView(R.id.ivStoryItemImg));
            baseViewHolder.setText(R.id.tvStoryItemName,bean.getName());
            Date date=TimeUtils.string2Date(bean.getCreateAt(),new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",Locale.CHINA));
            baseViewHolder.setText(R.id.tvStoryItemTime,TimeUtils.date2String(date,new SimpleDateFormat("yyyy-MM-dd")));
        }
    }
}
